home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMP Graphics Collection
/
AMP Graphics Collection.iso
/
programs
/
author
/
dirwin
/
data.z
/
ANIMWIZ.DIR
/
00010_Script_Credits
< prev
next >
Wrap
Text File
|
1996-03-15
|
18KB
|
533 lines
-- Credits script
property ioFieldList
property iFieldFocus
property ioFieldFocus
property iCurrentMotionStyleIndex
property iCurrentVisualStyleIndex
-- The motion styles are:
property ikMotionScrollingUp -- 1
property ikMotionIndividual -- 2
property iFirstTIme
property iSaveSeconds
property iSaveFPS
property iSaveDelayEnter
property iSaveDelayHold
property iSaveMark
property iSaveCycles
on birth me
global goCreditsText
global goSeconds
global goFPS
global goDelayEnter
global goDelayHold
-- global goCycles
set ioFieldList = [goCreditsText, goSeconds, goFPS, goDelayEnter, goDelayHold]
set ikMotionScrollingUp = 1
set ikMotionIndividual = 2
set iCurrentMotionStyleIndex = ikMotionScrollingUp
set iCurrentVisualStyleIndex = 1
set iFieldFocus = 1
set iFirstTime = TRUE
return me
end birth
on mInit me
global goSeconds
global goFPS
global goDelayEnter
global goDelayHold
--global goCycles
global goCredits
global goMarkFrame
global goVisualStyles
global goMotionStyles
global goScoreMgr
global goAnimateTitle
-- CheckMark parameter: channel
mInit(goMarkFrame, 4) -- channel
if iFirstTime then -- use intellegent defaults
mSetValue(goSeconds, 5)
mSetValue(goFPS, 5)
mSetValue(goDelayEnter, 5)
mSetValue(goDelayHold, 0)
-- mSetValue(goCycles, 1)
mSetValue(goMarkFrame, TRUE)
set iFirstTime = FALSE
else -- use values saved from when we last left
mSetValue(goSeconds, iSaveSeconds)
mSetValue(goFPS, iSaveFPS)
mSetValue(goDelayEnter, iSaveDelayEnter)
mSetValue(goDelayHold, iSaveDelayHold)
--mSetValue(goCycles, iSaveCycles)
mSetValue(goMarkFrame, iSaveMark)
end if
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
-- RadioButtons parameters: channel, nChannels, rightAnswer, default
set goMotionStyles = 0
set goMotionStyles = birth(script "RadioButton", 26, 2, 0, iCurrentMotionStyleIndex)
-- VisualStyles Params: castNum, default, nItems, channel
if the machineType < 256 then
mInit(goVisualStyles, the number of cast "CreditsVisualStylesMac", ¼
iCurrentVisualStyleIndex, 8, 19)
else
mInit(goVisualStyles, the number of cast "CreditsVisualStylesPC", ¼
iCurrentVisualStyleIndex, 8, 19)
end if
-- For keystroke validity checking
set the keydownscript = "mCheckKey(goCredits)"
end mInit
on mSetFieldFocus me, oWhom
set where = getOne(ioFieldList, oWhom)
if where = 0 then
alert("Internal error - mSetFieldFocus could not find object")
return
end if
set iFieldFocus = where
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
end mSetFieldFocus
on mCheckKey me
if the Key = TAB then -- change focus to the next field
set iFieldFocus = IncrMod(iFieldFocus, count(ioFieldList))
set ioFieldFocus = GetAt(ioFieldList, iFieldFocus)
pass -- pass the event so the hilight goes to the next field
else
if iFieldFocus = 1 then -- the text entry field, allow anything
pass
else -- numeric fields, only allow digits
if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
pass
else
dontPassEvent -- restrict only to digits.
end if
end if
end if
end mCheckKey
on mSetNewMotionStyle me, theNewStyleIndex
set iCurrentMotionStyleIndex = theNewStyleIndex
end mSetNewMotionStyle
on mSetNewVisualStyle me, theNewStyleIndex
set iCurrentVisualStyleIndex = theNewStyleIndex
end mSetNewVisualStyle
on mValidate me
-- Attempt to validate the last field of focus
set lastFieldOKFlag = mValidate(ioFIeldFocus)
return lastFieldOKFlag
end mValidate
-- Check to ensure that all lines have a colon in them
on mCheckFormat me
set theText = field("CreditsText")
set nLines = the number of lines in theText
repeat with thisLine = 1 to nLines
if offset(":", line thisLine of field("CreditsText")) = 0 then
alert("Line" && thisLine && "of the Credits text does not contain a colon.")
return FALSE
end if
end repeat
return TRUE
end mCheckFormat
on mParseLine me, theLineToParse, theHeaderFont, theHeaderSize, theBodyFont, theBodySize
global gCastNumTextAsBitmap
set where = offset(":", theLineToParse)
set theHeaderText = char 1 to where of theLineToParse
set nChars = the number of chars in theLineToParse
set theBodyText = char (where + 1) to nChars of theLineToParse
set castNumHeader = mModifyRichTextCM(goCastMgr, ¼
theHeaderText, theHeaderFont, theHeaderSize)
if castNumHeader = 0 then -- error
return FALSE
end if
-- The following does an effective "Convert to bitmap" into a
-- known bitmap cast member to get size info.
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumHeader
set widthHeader = the width of member gCastNumTextAsBitmap
set heightHeader = the height of member castNumHeader / ¼
the number of lines in (the text of member castNumHeader)
-- Create a cast member in the stage movie
set castNumHeaderTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member castNumHeader
tell the stage
pasteClipboardInto member castNumHeaderTarget
set the name of member castNumHeaderTarget = "RichText" && string(the ticks)
end tell
-- And again for the Body
set castNumBody = mModifyRichTextCM(goCastMgr, ¼
theBodyText, theBodyFont, theBodySize)
if castNumBody = 0 then -- error
return FALSE
end if
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumBody
set widthBody = the width of member gCastNumTextAsBitmap
set heightBody = the height of member castNumBody / ¼
the number of lines in (the text of member castNumBody)
-- Create a cast member in the stage movie
set castNumBodyTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member castNumBody
tell the stage
pasteClipboardInto member castNumBodyTarget
set the name of member castNumBodyTarget = "RichText" && string(the ticks)
end tell
return [castNumHeaderTarget, castNumBodyTarget, widthHeader, heightHeader,¼
widthBody, heightBody]
end mParseLine
on mSplitAndCreate2 me, theTextToParse, theHeaderFont, theHeaderSize, ¼
theBodyFont, theBodySize
global gCastNumTextAsBitmap
set nLines = the number of lines in theTextToParse
set theHeaderText = ""
set theBodyText = ""
repeat with thisLine = 1 to nLines
set theLineToParse = line thisLine of theTextToParse
set where = offset(":", theLineToParse)
set theHeaderPart = char 1 to where of theLineToParse
set nChars = the number of chars in theLineToParse
set theBodyPart = char (where + 1) to nChars of theLineToParse
if thisLine > 1 then
set theHeaderText = theHeaderText & RETURN
set theBodyText = theBodyText & RETURN
end if
set theHeaderText = theHeaderText & theHeaderPart
set theBodyText = theBodyText & theBodyPart
end repeat
set castNumHeader = mModifyRichTextCM(goCastMgr, ¼
theHeaderText, theHeaderFont, theHeaderSize)
if castNumHeader = 0 then -- error
return FALSE
end if
-- The following does an effective "Convert to bitmap" into a
-- known bitmap cast member to get size info.
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumHeader
set widthHeader = the width of member gCastNumTextAsBitmap
set heightHeader = the height of member castNumHeader
-- Create a cast member in the stage movie
set castNumHeaderTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member castNumHeader
tell the stage
pasteClipboardInto member castNumHeaderTarget
set the name of member castNumHeaderTarget = "RichText" && string(the ticks)
end tell
-- And again for the Body
set castNumBody = mModifyRichTextCM(goCastMgr, ¼
theBodyText, theBodyFont, theBodySize)
if castNumBody = 0 then -- error
return FALSE
end if
set the picture of member gCastNumTextAsBitmap = ¼
the picture of member castNumBody
set widthBody = the width of member gCastNumTextAsBitmap
set heightBody = the height of member castNumBody
-- Create a cast member in the stage movie
set castNumBodyTarget = mFindFreeCastRun(goCastMgr, 1, 1)
copyToClipBoard member castNumBody
tell the stage
pasteClipboardInto member castNumBodyTarget
set the name of member castNumBodyTarget = "RichText" && string(the ticks)
end tell
return [castNumHeaderTarget, castNumBodyTarget, widthHeader, heightHeader,¼
widthBody, heightBody]
end mSplitAndCreate2
on mCreate me
global goMarkFrame
global goMotionStyles
global goVisualStyles
global goScoreMgr
global goCastMgr
global gDevelopmentFlag
global gCastNumTextAsBitmap
if not(mValidate(me)) then
return
end if
if the last char of field "CreditsText" = RETURN then
delete the last char of field "CreditsText"
end if
if field("CreditsText") = EMPTY then
alert("Please enter some text for the Credit.")
return
end if
if not(mCheckFormat(me)) then
return
end if
tell the stage
set theStageFrame = the frame
end tell
set castNumVisualStyle = mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
set theVisualStyleName = the name of cast castNumVisualStyle
set theHeaderFont = word 2 of theVisualStyleName
set theHeaderSize = word 3 of theVisualStyleName
set theBodyFont = word 4 of theVisualStyleName
set theBodySize = word 5 of theVisualStyleName
set theSeconds = integer(field "Seconds")
set fps = integer(field "FPS")
set nFrames = integer(theSeconds * fps)
set delayEnter = integer(field "DelayEnter")
set delayHold = integer(field "DelayHold")
-- set nCycles = integer(field "Cycles")
set markFirst = mGetValue(goMarkFrame)
set theForeColor = 255
set theBackColor = 0
if (iCurrentMotionStyleIndex = ikMotionScrollingUp) then
set thisList = mSplitAndCreate2(me, field "CreditsText",¼
theHeaderFont, theHeaderSize, theBodyFont, theBodySize)
if thisList = FALSE then --error
return
end if
-- thisList contains the following for the line:
-- [castNumHeaderTarget, castNumBodyTarget, widthHeader, heightHeader,¼
widthBody, heightBody]
set castNumHeader = getAt(thisList, 1)
set castNumBody = getAt(thisList, 2)
set theWidthHeader = getAt(thisList, 3)
set theHeightHeader = getAt(thisList, 4)
set theWidthBody = getAt(thisList, 5)
set theHeightBody = getAt(thisList, 6)
-- Call the ScoreMgr to set up the score, # of frames, and 2 channel
-- set nTotalFrames = delayEnter + nFrames
if delayEnter > 0 then
set nTotalFrames = nFrames + 1
else set nTotalFrames = nFrames
if not(mInit(goScoreMgr, nTotalFrames, 2)) then
return
end if
set chHeader = mGetNextSelectedChannel(goScoreMgr)
set chBody = mGetNextSelectedChannel(goScoreMgr)
set theFrameNum = mGetStartFrame(goScoreMgr)
-- Mark first frame upon request
if markFirst then
set theLabel = "AW.Credit." & word 1 of the text of field "CreditsText" & " " & ¼
mGetGeneratedScoreSelection(goScoreMgr)
mWriteFrameLabel(goScoreMgr, theFrameNum, theLabel)
end if
-- Insert delay at entry upon request
-- if delayEnter > 0 then
-- mWriteFrameDelay(goScoreMgr, theFrameNum, delayEnter)
-- set theFrameNum = theFrameNum + delayEnter
-- end if
if delayEnter > 0 then
mWriteFrameDelay(goScoreMgr, theFrameNum, delayEnter)
mWriteFrameTempo(goScoreMgr, (theFrameNum + 1), fps)
set theFrameNum to theFrameNum + 1
else
mWriteFrameTempo(goScoreMgr, theFrameNum , fps)
mWriteFrameTempo(goScoreMgr, (theFrameNum + 1), 0)
end if
-- mWriteFrameTempo(goScoreMgr, theFrameNum, fps)
set theStageWidth = mGetStageWidth(goScoreMgr)
set theStageHeight = mGetStageHeight(goScoreMgr)
set totalTextWidth = theWidthHeader + theWidthBody
set xLocHeader = integer((theStageWidth / 2) - (totalTextWidth / 2))
set xLocBody = integer(xLocHeader + theWidthHeader)
set maxHeight = max(theHeightHeader, theHeightBody)
set yStart = theStageHeight - 10
set yEnd = 0 - maxHeight - 10
set yInc = float( yEnd - yStart ) / float(nFrames)
-- Generate the score fragment
--repeat with thisCycle = 1 to nCycles
set yLoc = yStart
tell the stage
beginRecording
repeat with thisFrame = 1 to nFrames
-- put theFrameNum &&theCh && castNumberTarget && xLoc && yLoc
mWriteSpriteRange(goScoreMgr, theFrameNum, chHeader, castNumHeader, ¼
theForeColor, theBackColor, xLocHeader, yLoc, 0, 0)
mWriteSpriteRange(goScoreMgr, theFrameNum, chBody, castNumBody, ¼
theForeColor, theBackColor, xLocBody, yLoc, 0, 0)
set theFrameNum = theFrameNum + 1
set yLoc = integer(yLoc + yInc)
end repeat
endRecording
end tell
else -- ikMotionIndividual
-- Call the ScoreMgr to set up the score, # of frames, and 2 channels
set nSourceLines = the number of lines in field "CreditsText"
-- set nFrames = (delayEnter + delayHold) * nSourceLines
set nFrames = (delayEnter + 1)*nSourceLines
if not(mInit(goScoreMgr, nFrames, 2)) then
return
end if
set maxHeaderWidth = 0
set maxBodyWidth = 0
set castNumList = []
repeat with thisLine = 1 to nSourceLines
set thisList = mParseLine(me, line thisLine of field "CreditsText",¼
theHeaderFont, theHeaderSize, theBodyFont, theBodySize)
if thisList = FALSE then --error
return
end if
-- thisList contains the following for the line:
-- [castNumHeaderTarget, castNumBodyTarget, widthHeader, heightHeader,¼
widthBody, heightBody]
set thisCastNumHeaderTarget = getAt(thisList, 1)
set thisCastNumBodyTarget = getAt(thisList, 2)
set thisWidthHeader = getAt(thisList, 3)
set thisHeightHeader = getAt(thisList, 4)
set thisWidthBody = getAt(thisList, 5)
set thisHeightBody = getAt(thisList, 6)
if thisWidthHeader > maxHeaderWidth then
set maxHeaderWidth = thisWidthHeader
end if
if thisWidthBody > maxBodyWidth then
set maxBodyWidth = thisWidthBody
end if
add(castNumList, [thisCastNumHeaderTarget, thisCastNumBodyTarget])
end repeat
set theForeColor = 255
set theBackColor = 0
set chHeader = mGetNextSelectedChannel(goScoreMgr)
set chBody = mGetNextSelectedChannel(goScoreMgr)
set theFrameNum = mGetStartFrame(goScoreMgr)
-- Mark first frame upon request
if markFirst then
set theLabel = "AW.Credit." & word 1 of the text of field "CreditsText" & " " & ¼
mGetGeneratedScoreSelection(goScoreMgr)
mWriteFrameLabel(goScoreMgr, theFrameNum, theLabel)
end if
set theStageWidth = mGetStageWidth(goScoreMgr)
set theStageHeight = mGetStageHeight(goScoreMgr)
set totalTextWidth = maxHeaderWidth + maxBodyWidth
set xLocHeader = integer((theStageWidth / 2) - (totalTextWidth / 2))
set xLocBody = integer(xLocHeader + maxHeaderWIdth)
set yLoc = integer(theStageHeight / 2)
repeat with thisLine = 1 to nSourceLines
mWriteFrameTempo(goScoreMgr, theFrameNum, fps)
set thisCastNumList = getAt(castNumList, thisLine)
set castNumHeader = getAt(thisCastNumList, 1)
set castNumBody = getAt(thisCastNumList, 2)
tell the stage
beginRecording
repeat with thisFrame = 1 to delayEnter
-- Generate the score fragment
-- put theFrameNum &&theCh && castNumberTarget && xLoc && yLoc
mWriteSpriteRange(goScoreMgr, theFrameNum, chHeader, castNumHeader, ¼
theForeColor, theBackColor, xLocHeader, yLoc, 0, 0)
mWriteSpriteRange(goScoreMgr, theFrameNum, chBody, castNumBody, ¼
theForeColor, theBackColor, xLocBody, yLoc, 0, 0)
set theFrameNum = theFrameNum + 1
end repeat
endRecording
end tell
if delayHold > 0 then
mWriteFrameDelay(goScoreMgr, theFrameNum , delayHold)
mWriteSprite(goScoreMgr, theFrameNum, chHeader, castNumHeader, ¼
theForeColor, theBackColor, xLocHeader, yLoc, 0, 0)
mWriteSprite(goScoreMgr, theFrameNum, chBody, castNumBody, ¼
theForeColor, theBackColor, xLocBody, yLoc, 0, 0)
set theFrameNum = theFrameNum + 1
--**** set theFrameNum = theFrameNum + delayHold
end if
end repeat
end if
go label("Credits") + 2 -- to display reselect button
if not(gDevelopmentFlag) then
tell the stage
go frame theStageFrame
end tell
end if
mClean(goScoreMgr)
end mCreate
on mCleanup me
global goMotionStyles
global goSeconds
global goFPS
global goDelayEnter
global goDelayHold
--global goCycles
global goMarkFrame
mCleanup(goMotionStyles)
set iSaveSeconds = mGetValue(goSeconds)
set iSaveFPS = mGetValue(goFPS)
set iSaveDelayEnter = mGetValue(goDelayEnter)
set iSaveDelayHold = mGetValue(goDelayHold)
--set iSaveCycles = mGetValue(goCycles)
set iSaveMark = mGetValue(goMarkFrame)
mCleanup(goMarkFrame)
end mCleanup